package editAir.editContent
{
	import flash.filters.GlowFilter;
	import flash.text.AntiAliasType;
	import flash.text.StyleSheet;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;

	public final class FileTextUtil
	{
		public function FileTextUtil()
		{
		}

		public static function getTextFormat() : TextFormat {
			var textFormat : TextFormat = new TextFormat();
			textFormat.font = "宋体";
			textFormat.size = 13;
			textFormat.color = 0xffffff;
			return textFormat;
		}
		public static function css():StyleSheet
		{
			var css:StyleSheet = new StyleSheet();
			css.setStyle( ".darkRed" , { color:"#9f0000" , leading:5 } );
			css.setStyle( ".darkYellow" , { color:"#ff8040" , leading:5 } );
			css.setStyle( ".gary" , { color:"#323232" , leading:5 } );
			css.setStyle( ".red" , { color:"#ff0000" , leading:5 } );
			css.setStyle( ".green" , { color:"#00ff00" , leading:5 } );
			css.setStyle( ".blue" , { color:"#3277ff" , leading:5 } );
			css.setStyle( ".yellow" , { color:"#ffff00" , leading:5 } );
			css.setStyle( ".white" , { color:"#ffffff" , leading:5 } );
			css.setStyle( ".canary" , { color:"#ffffbb" , leading:5 } );
			css.setStyle( ".purple" , { color:"#c85afa" , leading:5 } );
			css.setStyle( ".orange" , { color:"#F68409" , leading:5 } );
			css.setStyle( ".white" , { color:"#ffffff" , leading:5 } );
			return css;
		}
		public static function getTextField( textformat:TextFormat = null, defultFilters:Boolean = true, width:uint = 0, isCenter:Boolean = false, multiline:Boolean = false, size:uint = 0, mouseEn:Boolean = false, styleSheet:StyleSheet = null ):TextField
		{
			var textField:TextField = new TextField()
			textField.antiAliasType = AntiAliasType.ADVANCED;
		
			
			textField.multiline = multiline;
			textField.filters = defultFilters ?  [new GlowFilter( 0x000000, .7 , 2, 2, 17, 1, false, false)] : null;
			var thistextformat:TextFormat;
			if (textformat == null)
			{
				thistextformat = getTextFormat();
				if (multiline) thistextformat.leading = 2;
				if (size)
					thistextformat.size = size;
				if (isCenter)
					thistextformat.align = TextFormatAlign.CENTER;
				textField.defaultTextFormat = thistextformat;
			}
			else
				textField.defaultTextFormat = textformat;
			if (!styleSheet)
			{
				textField.styleSheet = css();
				
			}
			else
			{
				textField.styleSheet = styleSheet;
			}
			textField.mouseEnabled = mouseEn;
			textField.selectable = false;
			// textField.multiline = true;
			if (width != 0)
			{
				textField.width = width;
				textField.wordWrap = true;
			}
			isCenter == true ? textField.autoSize = TextFieldAutoSize.CENTER : textField.autoSize = TextFieldAutoSize.LEFT;
			return textField;
		
		}
	}
}